#!/usr/bin/python
# coding:utf-8

"""
@author: 信长华
@contact: skywater@gmail.com
@software: PyCharm
@file: fastapi_web.py
@time: 2021/7/30 12:31
"""
import logging

import uvicorn

from web.core.server import create_app
from web.settings import settings

"""
项目目录主要参考 https://github.com/CoderCharm/fastapi-mysql-generator
"""
app = create_app()

if __name__ == "__main__":
    # 输出所有的路由
    for route in app.routes:
        if hasattr(route, "methods"):
            print({"path": route.path, "name": route.name, "methods": route.methods})
    # 屏蔽日志 https://stackoverflow.com/questions/67266573/how-to-disable-the-logging-of-uvicorn-fast-api-python

    uvicorn.run(
        app="fastapi_web:app",
        host="0.0.0.0",
        port=10086,
        reload=settings.DEBUG,
        debug=settings.DEBUG,
        workers=settings.WORKERS,
        log_level=logging.WARNING
    )
